
//验证字段不为空;
	function checkBlank(obj,str)
	{  
		var value = true;
		if(obj.value == "")
		{
			alert(str+"不能为空！");
			obj.focus();
			value=false;
		}
		return value;
	}

	//验证字段为数字;如果是数字，则返回true。
	function checkNum(obj,str)
	{
		var value = true;
		if(isNaN(obj.value))
		{
			alert(str+"只能为数字！");
			obj.focus();
			value = false;
		}
		return value;
	}
	
	function MaxLength(obj,str,maxLen)
	{
		var value = true;
		var strLen = obj.value.length;
		if(strLen>maxLen)
		{
			alert(str+"字段长度不能大于"+maxLen+"位");
			obj.focus();
			value = false;
		}
		return value;
	}
	function EqualLength(obj,str,Len)
	{
		var value = true;
		var strLen = obj.value.length;
		if(strLen!=Len)
		{
			alert(str+"字段长度必须为"+Len+"位");
			obj.focus();
			value = false;
		}
		return value;
	}
	function MinLength(obj,str,maxLen)
	{
		var value = true;
		var strLen = obj.value.length;
		if(value)
		{
			if(strLen<maxLen)
			{
				alert(str+"字段长度必须大于"+maxLen+"位");
				obj.focus();
				value = false;
			}
		}
		return value;
	}

	function testMax(obj,str,maxLen)
	{
		var value = true;
		var strLen = parseInt(obj.value);
		if(strLen>maxLen)
		{
			alert(str+"不能大于"+maxLen);
			obj.focus();
			value = false;
		}
		return value;
	}
	
	function testMin(obj,str,minLen)
	{
		var value = true;
		var strLen = parseInt(obj.value);
		if(strLen<minLen)
		{
			alert(str+"不能小于"+minLen);
			obj.focus();
			value = false;
		}
		return value;
	}
	
	function IsDate(obj,str)
	{
		var value = true;
		var regExp = /^(\d{4})[-](\d{2})[-](\d{2})$/;
		var matchArray=regExp.test(obj.value);
		if (matchArray==false) 
		{
			alert(str+"日期格式不正确！");
			obj.focus();
			value = false;
		}
		return value;
	}
	
	function IsDateFormat(obj,str,format)
	{
		var regExp
		if(format=='yyyy'){
			regExp = /^(\d{4})$/
		}else if(format=='yyyy-MM-dd'){
			regExp = /^(\d{4})[-](\d{2})[-](\d{2})$/;
		}else if(format=='yyyy-MM'){
			regExp = /^(\d{4})[-](\d{2})$/
		}else {
			alert("日期格式不正确!");
			obj.focus();
			return false;
		}
		var value = true;
		var matchArray=regExp.test(obj.value);
		if (matchArray==false) 
		{
			alert(str+"日期格式不正确！");
			obj.focus();
			value = false;
		}
		return value;
	}
	
	//测试字段是否为整数;
	function checkInt(obj,str)
	{
		var value = true;
		var rule = /^[0-9]*[1-9][0-9]*$/;//正则表达式在/与/之间
		if(!rule.test(obj.value))
		{
			alert(str+"必须为整数！");
			obj.focus();
			value = false;
		}
		return value;
	}

	//测试字段是否由英文与数字组成;
	function checkCharNumber(obj,str)
	{
		var value = true;
		//var rule = /([0-9])([A-Za-z])/;//正则表达式在/与/之间
		//var str2 = /\d/;
		//var str1=/[A-Za-z]/;
		var regExp = /[^A-Za-z0-9_]/;
		if(regExp.test(obj.value))
		{
			//alert(str+"必须由数字、英文字母和下划线组成！");
			alert(str+"只能包含英文字母、数字和下划线");
			obj.focus();
			value = false;
		}
		return value;
	}

	//测试字段只能由英文或数字组成
	function checkEnglish(obj,str)
	{
		var value = true;
		//var rule = /([0-9])([A-Za-z])/;//正则表达式在/与/之间
		//var str2 = /\d/;
		//var str1=/[A-Za-z]/;
		var regExp = /[^A-Za-z0-9_]/;
		if(regExp.test(obj.value))
		{
			alert(str+"必须由数字或英语组成！");
			obj.focus();
			value = false;
		}
		return value;
	}

	//测试电话号码
	function checkTelephone(obj,str)
	{
		var value = true;
		var regExp = /[^0-9-]/;
		if(regExp.test(obj.value))
		{
			alert(str+"格式不正确！");
			obj.focus();
			value = false;
		}
		return value;
	}
	//测试手机号码
	function checkMobilePhone(obj,str)
	{
		var value = true;
		var regExp = /^(13[0-9]|15[0|3|6|8|9])\d{8}$/;
		var test = regExp.test(obj.value);
		//alert(test);
		if(!test){
		alert(str+"格式不正确");
		obj.focus();
		value = false;
		}
		return value;
	}
	function checkMail(obj)
	{
		var value = true;
		var checkMail=/^(.+)@(.+)$/;
		var matchArray=obj.value.match(checkMail);
		if (matchArray==null&&obj.value!="") 
		{
			alert("电子邮件地址不正确！");
			obj.focus();
			value=false;
		}
		return value;
	}

	/**
	 *	比较字符串大小;
	 */
	 function testBg(bigStr,smallStr)
	 {
	 	var testone = bigStr;
	 	var testTwo = smallStr;
	 	if(parseInt(testone) && parseInt(testTwo))
		{
			bigStr = parseInt(testone);
			smallStr = parseInt(testTwo);
		}
		return bigStr>smallStr?true:false;
	 }

	/**
	 * 比较两字符串大小
	 */
	function compareStrDate(first,second,info)
	{
		var value = true;
		var fir = first.value;
		var sec = second.value;
		if (testBg(fir,sec)) 
		{
			alert(info.replace(" ",""));
			second.focus();
			value = false;
		}
		return value;
	}

	function testEquals(first,second,info)
	{
		var value = true;
		var fir = first.value;
		var sec = second.value;
		if (fir==sec) 
		{
			alert(info);
			first.focus();
			value = false;
		}
		return value;
	}
	
	//验证字段不为空;
	function checkFile(obj)
	{
		var value = true;
		if(obj.value == "")
		{
			alert("上传文件不能为空！");
			obj.focus();
			value = false;
		}
		return value;
	}

	function checkEffDate(obj,str)
	{
		var value = true;
		var d = new Date();
		var mon = d.getMonth()+1;
		var datt = d.getDate();
		if(mon<10)
			mon = "0";
		else
			mon="";
		if(datt<10)
			datt ="0";
		else
			datt = "";
		var dateStr = d.getYear()+""+mon+(d.getMonth()+1)+""+datt+d.getDate();
		//alert(dateStr);
		if(dateStr>=obj.value)
		{
			alert(str+"只能大于当天!");
			obj.focus();
			value = false;
		}
		return value;
	}